<?php
/*
 * Example:
 *		include_partial('homepage/customdropdown', array('choices' => array('choice1_id' => 'choice1_name','choice2_id' => 'choice2_name',), 'input' => array('label' => 'Label','id' => 'foo', 'name' => 'bar')))
 *
 */
?>
<div class="dropdown custom-dropdown">
	<div class="dropdownlabel">
		<div class="dropdownleft"><img src="/enermaatik/img/dropleft.png" width="6" height="23" alt=""/></div>
		<div class="drop">
			<div class="droptext"><div class="custom-dropdown-label"><?php echo $input['label'] ?></div></div>
		</div>
		<div class="dropdownright"><img src="/enermaatik/img/dropright.png" width="25" height="23" alt=""/></div>
	</div>
	<div class="input dropdowninput" style="display:none">
		<input type="text" id="<?php echo $input['plugin_input_id'] ?>" class="autocomplete">
	</div>
	
		<input type="hidden" id="<?php echo $input['input_id'] ?>" value="<?php echo $input['value'] ?>" class="<?php echo $input['class'] ?> dropdowninputreal" name="<?php echo $input['name'] ?>">
	
	<div class="clear"></div>
</div>

<?php
use_stylesheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css');
use_javascript('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js');
?>
<script type="text/javascript">
	<?php 
		$choices_str = '';
		foreach($choices as $choice_index => $choice_val)
			$choices_str .= '{label: "'. $choice_val  .'", key:"'. $choice_index.'"},';
		$choices_str = '[' . trim($choices_str, ',') . ']';
	?>

	$(document).ready(function(){
		$('#<?php echo $input['plugin_input_id'] ?>').autocomplete('option', 'source' , <?php echo $choices_str ?>);
	});	
</script>